<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
         function Person () {
            this.eyes = 2
            this.head = 1
        }

        // 女人 想要继承Person
        function Woman () {
            
        }
        // Woman通过原型来继承Person
        // 父构造函数(父类) 子构造函数(子类)
        // 子类的原型 = new 父类
        Woman.prototype = new Person()
        Woman.prototype.constructor = Woman
        Woman.prototype.baby = function () {
            console.log('baby')
        }
        const w1 = new Woman()
        console.log(w1)



        // 手机
        function Phone (brand, price) {
            this.brand = brand
            this.price = price
        }
        Phone.prototype.call = function () {
            console.log('call')
        }

        // 智能手机
        function SmartPhone (brand, price, color, size) {
            // this -> SmartPhone的实例对象
            Phone.call(this, brand, price)
            this.color = color
            this.size = size
        }

        //设置子级构造函数的原型
        SmartPhone.prototype = new Phone()
        SmartPhone.prototype.constructor = SmartPhone
        SmartPhone.prototype.play = function () {
            console.log('play')
        }
        let s = new SmartPhone('1+',1999,'红',18)
        console.log(s)




    </script>
</body>
</html>